package pt.ipl.isel.deetc.leic.pdm.g12.yamba;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;

public class NetworkReceiver extends BroadcastReceiver {
  public static final String TAG = "NetworkReceiver";

  @Override
  public void onReceive(Context context, Intent intent) {

    boolean isOffline = intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);
    
    if (!isOffline) {
    	Intent intentUploadStatus = new Intent(context, StatusUploadService.class);    	
		intentUploadStatus.putExtra(StatusUploadService.ARG_ACTION, "postOffline");
		context.startService(intentUploadStatus);		
		intentUploadStatus.removeExtra(StatusUploadService.ARG_ACTION);
    }
  }

}
